//
//  BaseViewController.m
//  SchoolClient
//
//  Created by mac on 15/10/27.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initNavigationBar];
    
}

-(void)initNavigationBar{

    //页面不向四周边缘展开
    [self setEdgesForExtendedLayout:UIRectEdgeNone];
    self.view.backgroundColor = [UIColor whiteColor];
    //导航条颜色
    UIColor *bgColor = [Tools getColor:@"43bee0"];
    self.navigationController.navigationBar.barTintColor = bgColor;
    //富文本属性
    NSMutableDictionary *titleDic = [NSMutableDictionary dictionary];
    titleDic[NSFontAttributeName] = [UIFont boldSystemFontOfSize:18];
    titleDic[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:titleDic];
    //设置导航按扭的颜色为白色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    
    //设置状态栏背景色为黑色
    UIView *stateView = [[UIView alloc]initWithFrame:CGRectMake(0, -20, self.view.frame.size.width, 20)];
    stateView.backgroundColor = [UIColor blackColor];
    [self.navigationController.navigationBar addSubview:stateView];
    //设置状态栏前景色为白色
    //[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];
    [UIApplication sharedApplication].statusBarStyle = [self preferredStatusBarStyle];
    
    //左边返回导航按钮
    if (self.navigationController.childViewControllers.count != 1) {  // 不是根控制器
        
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"navigationbar_arrow_back"] style:UIBarButtonItemStylePlain target:self action:@selector(comeBack)];
    }
}

- (UIStatusBarStyle)preferredStatusBarStyle{
    
   return UIStatusBarStyleLightContent;
}


-(void)initTableView{
    
    CGRect aRect = CGRectMake(self.view.bounds.origin.x,
                              self.view.bounds.origin.y,
                              self.view.bounds.size.width,
                              self.view.bounds.size.height - 64);
    self.tableView = [[UITableView alloc] initWithFrame:aRect  style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview: self.tableView];
}

- (void)comeBack
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark overide UITableViewDataSource methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"tableviewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    return cell;
}


@end
